<?php

//isset() 函数用于检测变量是否已设置并且非 NULL
//如果为空 当前页为1 
$curPage = isset($_GET['curPage'])?$_GET['curPage']:1;
$maxPage = 20;

$pageNumString = '';

if ($curPage<=5) {
	$begin = 1;
	$end = 10;
}else {
	$end = ($curPage + 5)<$maxPage?($curPage + 5):$maxPage;
	$begin = ($end - 9)<0?1:$end - 9;
}

for ($i=$begin; $i <=$end ; $i++) { 
	if ($curPage == $i) {
		$pageNumString .= "<a href='paging_system.php?curPage=$i'><font color='red'>$i</font></a>&nbsp;&nbsp;";
	}else {
		$pageNumString .= "<a href='paging_system.php?curPage=$i'>$i</a>&nbsp;&nbsp;";
	}
}

echo $pageNumString;

?>